<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
?>
<script type="text/javaScript"><!--//--><![CDATA[//><!--

function editSkillAlw() {

	if(document.EditSkill.title=='Save') {
		editEXTSkillAlw();
		return;
	}

	var frm=document.frmEmp;
	for (var i=0; i < frm.elements.length; i++)
		frm.elements[i].disabled = false;

	document.EditSkill.src="../../themes/beyondT/pictures/btn_save.gif";
	document.EditSkill.title="Save";
}


function addEXTSkillAlw() {

	if(document.frmEmp.cmbSkilAlwId.value=='0') {
		alert("必须选择技能津贴");
		document.frmEmp.cmbSkilAlwId.focus();
		return;
	}
	
	document.frmEmp.skillAlwSTAT.value="ADD";
	qCombo(22);
}

function decimal(txt) {
	regExp = /^[0-9]+(\.[0-9]+){0,1}$/;

	if (regExp.test(txt)) {
		return true;
	}

	return false;
}

function editEXTSkillAlw() {

	if(document.frmEmp.cmbSkilAlwId.value=='0') {
		alert("必须选择技能津贴");
		document.frmEmp.cmbSkilAlwId.focus();
		return;
	}

	document.frmEmp.skillAlwSTAT.value="EDIT";
	qCombo(22);
}

function delEXTSkillAlw() {

	var check = false;
	with (document.frmEmp) {
		for (var i=0; i < elements.length; i++) {
			if ((elements[i].name == 'chkskillalwdel[]') && (elements[i].checked == true)) {
				check = true;
			}
		}
	}

	if(!check) {
		alert('<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>')
		return;
	}

    document.frmEmp.skillAlwSTAT.value="DEL";
    qCombo(22);
}

function viewSkillAlw(skillalw) {
	document.frmEmp.action = document.frmEmp.action + "&SKILL_ALW=" + skillalw;
	document.frmEmp.pane.value = 22;
	document.frmEmp.submit();
}

function getAlwSalary(sel_alw_id) {
	if(sel_alw_id==0) document.frmEmp.txtSkillAlwSalary.value = 0;
	else {
		var data = eval(<?php echo json_encode($this->popArr['uskillalwlist']);?>)
		for (var i=0; i < data.length; i++) {
			if(data[i][0]==sel_alw_id) {
				document.frmEmp.txtSkillAlwSalary.value = data[i][3];
				break;
			}
		}
	}
}
//--><!]]></script>
<div id="parentPaneSkills" >
<?php if(isset($this->getArr['capturemode']) && $this->getArr['capturemode'] == 'updatemode') { ?>
    <input type="hidden" name="skillAlwSTAT" value=""/>
<?php
if(isset($this->popArr['editSkillAlwArr'])) {
    $edit = $this->popArr['editSkillAlwArr'];
?>
	<div id="editPaneSkillAlws" >
	<table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
                    <tr>
                      <td width="200"><?php echo $lang_hrEmpMain_Skill?></td>
    				  <td><input type="hidden" name="cmbSkilAlwId" value="<?php echo $edit[0][1]?>"/><strong>
<?php						$allSkillAlwlist = $this->popArr['allSkillAlwlist'];
						for($c=0;count($allSkillAlwlist)>$c;$c++)
							if($this->getArr['SKILL_ALW']==$allSkillAlwlist[$c][0])
							     break;

					  	echo $allSkillAlwlist[$c][1];
?>
					  </strong></td>
					</tr>
					  <!--tr>
                      <td><?php echo $lang_hrEmpMain_yearofex?></td>
    				  <td><input type="text" name="txtEmpYears" id="etxtEmpYears" value="<?php echo isset($this->popArr['txtEmpYears']) ? $this->popArr['txtEmpYears'] : $edit[0][2]?>"/></td>
    				  <td width="50">&nbsp;</td>
					  </tr-->
					  <tr>
                      <td>技能加薪(元)</td>
    				  <td><input type="text" name="txtSkillAlwSalary" id="etxtSkillAlwSalary" value="<?php echo isset($this->popArr['txtSkillAlwSalary']) ? $this->popArr['txtSkillAlwSalary'] : $allSkillAlwlist[$c][3]?>" readonly/></td>
    				  <td width="50">&nbsp;</td>
					  </tr>

					  <tr>
						<td><?php echo $lang_Leave_Common_Comments?></td>
						<td> <textarea rows="3" cols="25" name="txtEmpAlwComments"><?php echo isset($this->popArr['txtEmpAlwComments']) ? $this->popArr['txtEmpAlwComments'] : $edit[0][2]?></textarea></td>
    				  <td width="50">&nbsp;</td>
					 </tr>
                  </table>
<?php	if($locRights['edit']) { ?>
<div class="formbuttons">
    <input type="button" class="savebutton" name="btnEditSkill" id="btnEditSkill"
    	value="<?php echo $lang_Common_Save;?>"
    	title="<?php echo $lang_Common_Save;?>"
    	onmouseover="moverButton(this);" onmouseout="moutButton(this);"
    	onclick="editEXTSkillAlw(); return false;"/>
    <input type="reset" class="resetbutton" value="<?php echo $lang_Common_Reset; ?>" />
</div>
<?php	} ?>
		</div>
<?php } else { ?>
<div id="addPaneSkillAlws" class="<?php echo ($this->popArr['rsetSkill'] != null)?"addPane":""; ?>" >
	<table width="100%" border="0" cellpadding="5" cellspacing="0" class="">
                    <tr>
                      <td width="200">技能津贴</td>
                      <?php
                      		$skillalwlist = $this->popArr['uskillalwlist'];
                      		//$alwlistjson = json_encode($skillalwlist);
                      ?>
    				  <td><select name="cmbSkilAlwId" <?php echo $locRights['add'] ? '':'disabled="disabled"'?> onChange="getAlwSalary(this.value)">
    				  		<option selected="selected" value="0">-----------选择技能津贴-------------</option>
<?php
						for($c=0;$skillalwlist && count($skillalwlist)>$c;$c++)
							   echo "<option value='" . $skillalwlist[$c][0] . "'>" . $skillalwlist[$c][1] . "</option>";
?>
					  </select></td>
					</tr>
                    <!--tr>
                      <td><?php echo $lang_hrEmpMain_yearofex?></td>
    				  <td><input type="text" name="txtEmpYears" <?php echo $locRights['add'] ? '':'disabled="disabled"'?> value="<?php echo isset($this->popArr['txtEmpYears']) ? $this->popArr['txtEmpYears'] :''?>"/></td>
    				  <td width="50">&nbsp;</td>
					</tr-->
                    <tr>
                      <td>技能加薪</td>
    				  <td><input type="text" name="txtSkillAlwSalary" id="alwSalary" value="" readonly/></td>
    				  <td width="50">&nbsp;</td>
					</tr>
					 <tr>
					<td><?php echo $lang_Leave_Common_Comments?></td>
						<td> <textarea <?php echo $locRights['add'] ? '':'disabled="disabled"'?> rows="3" cols="25" name="txtEmpAlwComments"><?php echo isset($this->popArr['txtEmpAlwComments']) ? $this->popArr['txtEmpAlwComments'] :''?></textarea></td>
    				  <td width="50">&nbsp;</td>
						 </tr>
					  <tr>
						<td valign="top"></td>
						<td align="left" valign="top">
						</td>
					  </tr>
                  </table>
<?php	if($locRights['add']) { ?>
<div class="formbuttons">
    <input type="button" class="savebutton" name="btnAddSkill" id="btnAddSkill"
    	value="<?php echo $lang_Common_Save;?>"
    	title="<?php echo $lang_Common_Save;?>"
    	onmouseover="moverButton(this);" onmouseout="moutButton(this);"
    	onclick="addEXTSkillAlw(); return false;"/>
    <input type="reset" class="resetbutton" value="<?php echo $lang_Common_Reset; ?>" />
</div>
<?php	} ?>
</div>
<?php } ?>
<?php
$rset = $this->popArr['rsetSkillAlw'] ;
$allSkillAlwlist = $this->popArr['allSkillAlwlist'];

if ($rset != null){ ?>
<div class="subHeading"><h3>添加技能津贴</h3></div>

<div class="actionbar">
	<div class="actionbuttons">
<?php if ($locRights['add']) { ?>
				<input type="button" class="addbutton"
					onclick="showAddPane('SkillAlws');" onmouseover="moverButton(this);" onmouseout="moutButton(this);"
					value="<?php echo $lang_Common_Add;?>" title="<?php echo $lang_Common_Add;?>"/>
<?php } ?>
<?php	if ($locRights['delete']) { ?>
				<input type="button" class="delbutton"
					onclick="delEXTSkillAlw();" onmouseover="moverButton(this);" onmouseout="moutButton(this);"
					value="<?php echo $lang_Common_Delete;?>" title="<?php echo $lang_Common_Delete;?>"/>

<?php 	} ?>
		</div>
	</div>

	<table width="100%" cellspacing="0" cellpadding="0" class="data-table">
	<thead>
		<tr>
			<td></td>
			<td>技能津贴</td>
			<td>技能加薪(元)</td>
			<td>注释</td>
		</tr>
	</thead>
	<tbody>
<?php

    for($c=0; $rset && $c < count($rset); $c++) {
		$cssClass = ($c%2) ? 'even' : 'odd';
    	echo '<tr class="' . $cssClass . '">';

            echo "<td><input type='checkbox' class='checkbox' name='chkskillalwdel[]' value='" . $rset[$c][1] ."'/></td>";

			for($a=0;count($allSkillAlwlist)>$a;$a++)
				if($rset[$c][1] == $allSkillAlwlist[$a][0]) {
				   $lname = $allSkillAlwlist[$a][1];
				   $lsalary = $allSkillAlwlist[$a][3];
				}
			?><td><a href="javascript:viewSkillAlw('<?php echo $rset[$c][1]?>')"><?php echo $lname?></a></td><?php
			echo '<td>'. $lsalary .'</td>';
			echo '<td>'. $rset[$c][2] .'</td>';

        echo '</tr>';
    }

?>
		</tbody>
     </table>
<?php } ?>
<?php } ?>
</div>